package com.atung.provider;

import java.util.Date;
import java.util.Objects;

import org.apache.ibatis.annotations.Param;

public class BusRoutPublishProvider {

	/**
	 * 列表
	 * @param routId
	 * @param startData
	 * @return
	 */
	public String selectRoutPublishByRoutIdProvider(@Param("routId")Long routId,@Param("startData")Date startData){
	
		StringBuffer sql=new StringBuffer();
		sql.append(" select bsor.departl_name,bsor.destination  ,brp.id ,brp.car_rid_price,brp.rout_publish_state,brp.expiration_date,brp.start_data  ");
		sql.append("  from  bus_rout_publish  brp inner join bus_school_open_route bsor on brp.rout_id=bsor.id  ");
		sql.append("  where brp.rout_id=#{routId} ");
		if(Objects.nonNull(startData)){
			sql.append(" and to_days (brp.start_data) = to_days(#{startData})  ");
		}
	
		
		sql.append(" and bsor.is_delect=0 and brp.is_delect=0 order by brp.start_data asc ");
		
		System.out.println(sql.toString());
		return sql.toString();
	}
	
	/**
	 * 详情
	 * @param publisId
	 * @return
	 */
	public String selectRoutPublishByIdProvider(@Param("publisId")Long publisId){
		StringBuffer sql=new StringBuffer();
		sql.append(" select bsor.departl_name,bsor.destination  ,brp.id ,brp.car_rid_price,brp.rout_publish_state,brp.expiration_date,brp.start_data  ");
		sql.append("  from  bus_rout_publish  brp inner join bus_school_open_route bsor on brp.rout_id=bsor.id  ");
		sql.append("  where brp.id=#{publisId} ");	
		sql.append(" and bsor.is_delect=0 and brp.is_delect=0 order by brp.start_data asc ");
		return sql.toString();
	}
	
}
